package com.gxa.worker.recycling.controller;

import com.gxa.core.recycling.anno.NeedToken;
import com.gxa.core.recycling.common.ExceptionCode;
import com.gxa.core.recycling.common.JsonResult;
import com.gxa.core.recycling.exception.BusinessException;
import com.gxa.core.recycling.pojo.CommunityManage;
import com.gxa.core.recycling.pojo.User;
import com.gxa.worker.recycling.service.UserService;
import com.gxa.worker.recycling.service.VillageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author ：looker
 * @date ：Created in 2021/12/2 10:29
 */
@CrossOrigin
@RestController
@RequestMapping("/vill")
@Api("回收元前台-查找小区")
public class VillageController {

    @Autowired
    VillageService villageService;


    /**
     * 廖泓宇
     * 新建临时用户
     */
    @PostMapping("/selectName")
    @ApiOperation("根据省市区查找小区名")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "省市区", required = true, dataType = "String")
    })
    @NeedToken
    public Map createUser(@RequestParam String name){
        List<CommunityManage> communityManages = villageService.selectIdByName(name);
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        jsonResult.setData(communityManages);
        return jsonResult.getDataMap();
    }

}
